#ifndef _NE_GL_BUFFER_OBJECT_H_
#define _NE_GL_BUFFER_OBJECT_H_

#include <common/SharedPtr.h>
#include <graphics/GLObject.h>

namespace ne
{
    class NEAPI GLBufferObject : public GLObject
    {
        public:
            GLBufferObject(const BufferType bt, const BufferUsage usage, const uint32_t length);

            BufferType getType() const;

            BufferUsage getUsage() const;

            uint32_t getSize() const;

            bool isLocked() const;

            void* lock(const BufferAccess access, const uint32_t offset, const uint32_t length, const bool discardWholeBuffer=false);

            bool unlock();

            bool readData(const uint32_t offset, const uint32_t length, void *pDest);

            bool writeData(const uint32_t offset, const uint32_t length, const void *pSource, const bool discardWholeBuffer=false);

            bool copyDataFrom(GLBufferObject &srcVBO, const uint32_t srcOffset, const uint32_t destOffset, const uint32_t length, const bool discardWholeBuffer=false);

            bool copyDataFrom(GLBufferObject &srcVBO);

            virtual ~GLBufferObject();

        private:
            BufferType mType;
            BufferUsage mUsage;
            uint32_t mSize;
            bool mIsLocked;
    };

    typedef SharedPtr<GLBufferObject> GLBufferObjectPtr;
    typedef std::map<uint32_t, GLBufferObjectPtr> GLBufferObjectMap;
    typedef GLBufferObjectMap::iterator GLBufferObjectMapIterator;
    typedef GLBufferObjectMap::const_iterator GLBufferObjectMapConstIterator;
}

#endif
